home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / bc_pas_1.zip / INITHW.C < prev    next >
C/C++ Source or Header  |  1993-01-06  |  5KB  |  194 lines

  1. /*$Author:   DCODY  $*/
  2. /*$Date:   24 Sep 1992 08:49:42  $*/
  3. /*$Header:   X:/sccs/misc/inithw.c_v   1.4   24 Sep 1992 08:49:42   DCODY  $*/
  4. /*$Log:   X:/sccs/misc/inithw.c_v  $
  5.  * 
  6.  *    Rev 1.4   24 Sep 1992 08:49:42   DCODY
  7.  * changed MVGetHardware to mvGetHardware
  8.  * 
  9.  *    Rev 1.3   20 Jul 1992 11:45:58   DCODY
  10.  * changed mvGetHWVersion call to request relocatable I/O detection.
  11.  * 
  12.  *    Rev 1.2   17 Jul 1992 14:10:32   DCODY
  13.  * major re-write for new Pro Audio cards
  14.  * 
  15.  *    Rev 1.1   23 Jun 1992 16:33:12   DCODY
  16.  * PAS2 update
  17.  * 
  18.  *    Rev 1.0   15 Jun 1992 09:39:54   BCRANE
  19.  * Initial revision.
  20. */
  21. /*$Logfile:   X:/sccs/misc/inithw.c_v  $*/
  22. /*$Modtimes$*/
  23.  
  24.     /*\
  25.     |*|----====< INITHW.C >====----
  26.     |*|
  27.     |*| This module initializes the Pro Audio Spectrum from a cold boot
  28.     |*|
  29.     |*| Copyright (c) 1991, Media Vision, Inc. All rights reserved.
  30.     |*|
  31.     \*/
  32.  
  33. #include <stdio.h>
  34. #include <stdlib.h>
  35. #include <malloc.h>
  36.  
  37. #include "state.h"
  38. #include "mixers.h"
  39. #include "binary.h"
  40. #include "common.h"
  41. #include "target.h"
  42.  
  43.  
  44.     /* initial volume control states                                        */
  45.  
  46.     static unsigned char volumes[6][2] = {
  47.           0,  BI_VOLLOUD,            /*     0% - switch off                    */
  48.           0,  BI_VOLENHANCE,        /*     0% - switch off                    */
  49.          50,  BI_VOLBASS,            /*    50% - sliding scale                 */
  50.          50,  BI_VOLTREBLE,         /*    50% - sliding scale                 */
  51.          45,  BI_VOLLEFT,            /*    45% - sliding scale                 */
  52.          45,  BI_VOLRIGHT            /*    45% - sliding scale                 */
  53.     };
  54.  
  55.     static unsigned char mixersetting[16][3] = {
  56.          88,  BI_INPUTMIXER, BI_L_FM,        /* 88% of the sliding scale     */
  57.          88,  BI_INPUTMIXER, BI_R_FM,        /* 88% of the sliding scale     */
  58.  
  59.          55,  BI_OUTPUTMIXER, BI_L_IMIXER,    /* 55% of the sliding scale     */
  60.          55,  BI_OUTPUTMIXER, BI_R_IMIXER,    /* 55% of the sliding scale     */
  61.  
  62.          88,  BI_INPUTMIXER, BI_L_EXT,        /* 88% of the sliding scale     */
  63.          88,  BI_INPUTMIXER, BI_R_EXT,        /* 88% of the sliding scale     */
  64.  
  65.          88,  BI_INPUTMIXER, BI_L_INT,        /* 88% of the sliding scale     */
  66.          88,  BI_INPUTMIXER, BI_R_INT,        /* 88% of the sliding scale     */
  67.  
  68.          40,  BI_INPUTMIXER, BI_L_MIC,        /* 40% of the sliding scale     */
  69.          40,  BI_INPUTMIXER, BI_R_MIC,        /* 40% of the sliding scale     */
  70.  
  71.          88,  BI_INPUTMIXER, BI_L_PCM,        /* 88% of the sliding scale     */
  72.          88,  BI_INPUTMIXER, BI_R_PCM,        /* 88% of the sliding scale     */
  73.  
  74.          88,  BI_INPUTMIXER, BI_L_SPEAKER,    /* 88% of the sliding scale     */
  75.          88,  BI_INPUTMIXER, BI_R_SPEAKER,    /* 88% of the sliding scale     */
  76.  
  77.          88,  BI_INPUTMIXER, BI_L_SBDAC,    /* 88% of the sliding scale     */
  78.          88,  BI_INPUTMIXER, BI_R_SBDAC     /* 88% of the sliding scale     */
  79.  
  80.     };
  81.  
  82.  
  83.     /*\
  84.     |*|----====< int InitMVHardware( ) >====----
  85.     |*|
  86.     |*| This code initializes the ProAudio Spectrum mixer, volume,
  87.     |*| MIDI, FM, and PCM hardware to default states.
  88.     |*|
  89.     |*| Entry Conditions:
  90.     |*|     None
  91.     |*|
  92.     |*| Exit Conditions:
  93.     |*|     returns the hardware version of the card (currently 0)
  94.     |*|
  95.     \*/
  96. int InitMVHardware()
  97. {
  98. int n,i,x,hv,hvbits;
  99. int mvGetHWVersion(int);
  100.  
  101.     /* determine the feature set of this board                                */
  102.  
  103.         mvGetHWVersion(USE_ACTIVE_ADDR);
  104.         _asm {
  105.             mov     hv,ax
  106.             mov     hvbits,cx
  107.         }
  108.  
  109.     /* blow off the interrupts                                              */
  110.  
  111.         MVOut (INTRCTLR, 0xFF,0x00);
  112.  
  113.     /* take the board out of reset by writing a value to the filter         */
  114.  
  115.         MVOut(AUDIOFILT,0xFF,0x00);
  116.  
  117.     /* set the cross channel to LEFT-TO-LEFT, RIGHT-TO-RIGHT & kill PCM     */
  118.  
  119.         MVOut (CROSSCHANNEL,0xFF, bCCl2l+bCCr2r);
  120.  
  121.     /* initialize access to the mixers                                        */
  122.  
  123.         MVInitMixerCode(0);
  124.  
  125.     /* initialize the volume device                                         */
  126.  
  127.         for (n=0;n<6;n++)
  128.             cMVSetVolumeFunction(volumes[n][0], volumes[n][1]);
  129.  
  130.     /* initialize the input mixer for all channels                            */
  131.  
  132.         for (n=0;n<16;n++)
  133.             cMVSetMixerFunction
  134.               (
  135.                 mixersetting[n][0],
  136.                 mixersetting[n][1],
  137.                 mixersetting[n][2]
  138.               );
  139.  
  140.     /* turn off the realsound switch                                        */
  141.  
  142.         cMVRealSoundSwitch (0,1);
  143.  
  144.     /* set the FM into mono access mode, then flush them...                 */
  145.  
  146.         cMVFMSplitSwitch   (100,1);
  147.  
  148.         for (n=0;n<256;n++) {
  149.  
  150.             outp (0x388,n);
  151.  
  152.             for(x=i=0;i<3;i++)
  153.                 x += inp(0x388);
  154.  
  155.             outp (0x389,0);
  156.  
  157.             for(x=i=0;i<33;i++)
  158.                 x += inp(0x388);
  159.         }
  160.  
  161.     /* flush the MIDI interface                                             */
  162.  
  163.         if (hvbits & bMV101) {
  164.  
  165.             MVOut(MIDIPRESCALE, 0xFF,0x00);
  166.             MVOut(MIDICONTROL,    0xFF,bMCRrstfifoi+bMCRrstfifoi);
  167.             MVOut(MIDICONTROL,  0xFF,0x00);
  168.  
  169.         }
  170.         else {
  171.  
  172.             MVOut(MDSYSCTLR,0xFF,0x80);     // send a reset to the Yamaha
  173.  
  174.             for(x=i=0;i<33;i++)             // wait 80 microseconds
  175.                 x += inp(0x388);
  176.  
  177.             MVOut(MDSYSCTLR,0xFF,0x80);     // clear the reset
  178.  
  179.         }
  180.  
  181.     /* take the board out of reset by writing a value to the filter         */
  182.  
  183.         cMVSetFilterFunction(100);        /* set for no limiting                */
  184.  
  185.     /* return the hardware version #                                        */
  186.  
  187.         return (hv);
  188. }
  189.  
  190.     /*\
  191.     |*| end of INITHW.C
  192.     \*/
  193.  
  194.